home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-05 | 3.9 KB | 182 lines | [TEXT/PJMM] |
- unit DXClock;
-
- { cdev used to set the params of the init DX Clock }
- { started August 15 1991 }
- { creator : DXCL }
- { V1.0d1 }
-
- { released in the public domain january 5 1994 }
-
- interface
-
- uses
- Tools, Globals, Prefs;
-
- function Main (message, item, numItems, CPanelID: Integer; theEvent: EventRecord; cdevValue: LongInt; CPDialog: DialogPtr): LongInt;
-
- implementation
-
- procedure IGetRect (ourHandle: SampleHdl; item: Integer; var itemRect: Rect);
- Forward;
- procedure HitSample (ourHandle: SampleHdl; item: Integer; theEvent: EventRecord);
- Forward;
- function InitSample (CPDialog: DialogPtr; numItems: Integer): LongInt;
- Forward;
- function IGetCtlHand (ourHandle: SampleHdl; item: Integer): ControlHandle;
- Forward;
-
- function Main;
-
- var
- ourHandle: sampleHdl;
- storageExpected: Boolean;
- theStr: Str255;
- box: Rect;
- saveClip, theRgn: RgnHandle;
- thePat: PatHandle;
-
- begin
-
- storageExpected := not ((message = initDev) or (message = macDev));
- if storageExpected and ((cdevValue = 0) or (cdevValue = cdevUnset)) then
- cdevValue := 0
- else
- begin
- ourHandle := sampleHdl(cdevValue);
- case message of
- initDev:
- begin
- cdevValue := InitSample(CPDialog, numItems);
- ourHandle := sampleHdl(cdevValue);
- end;
- closeDev:
- if ourHandle <> nil then
- begin
- DisposHandle(Handle(ourHandle));
- cdevValue := 0;
- ourHandle := nil;
- end;
- updateDev:
- begin
- HLock(Handle(ourHandle));
- with ourHandle^^ do
- begin
- iGetRect(ourHandle, iPictRect, box);
- MoveTo(box.right - StringWidth(vers) - 5, box.bottom - 4);
- DrawString(vers);
- {UpdtDialog(CPDialog, CPDialog^.visRgn);}
- {ValidRect(CPDialog^.portRect);}
- end;
- HUnlock(Handle(ourHandle));
- end;
- activDev:
- begin
- HLock(Handle(ourHandle));
- HUnlock(Handle(ourHandle));
- end;
- deActivDev:
- begin
- HLock(Handle(ourHandle));
- HUnlock(Handle(ourHandle));
- end;
- cursorDev:
- SetCursor(QDGlobals^.arrow);
- hitDev:
- HitSample(ourHandle, item - numItems, theEvent);
-
- otherwise
- ;
- end; { Case }
- end;
- Main := cdevValue;
-
- end; { Main }
-
- {----------------------------------------------------------------}
-
- procedure IGetRect (ourHandle: sampleHdl; item: Integer; var itemRect: Rect);
-
- var
- itemHand: Handle;
- itemType: Integer;
-
- begin
-
- with ourHandle^^ do
- GetDItem(dlgPtr, item + dlgItems, itemType, itemHand, itemRect);
-
- end; { IGetRect }
-
- {----------------------------------------------------------------}
-
- function InitSample (CPDialog: DialogPtr; numItems: Integer): LongInt;
-
- var
- ourHandle: sampleHdl;
-
- begin
-
- ourHandle := sampleHdl(NewHandle(sizeOf(SampleStorage)));
- if ourHandle <> nil then
- begin
- with ourHandle^^ do
- begin
- dlgPtr := CPDialog;
- dlgItems := numItems;
- end; { With }
- end; { if }
- InitSample := Ord4(ourHandle);
-
- end; { InitSample }
-
- {----------------------------------------------------------------}
-
- procedure HitSample (ourHandle: SampleHdl; item: Integer; theEvent: EventRecord);
-
- const
- scrollConst = 5;
- maxY = 202;
-
- var
- thePoint: Point;
- theDialog: DIalogPtr;
- thePrefs: PrefHandle;
-
- begin
-
- thePoint := theEvent.where;
- GlobalToLocal(thePoint);
-
- case item of
- iSettings:
- begin
- thePrefs := prefHandle(GetResource('DXCL', 1));
- DoPrefs(thePrefs);
- ReleaseResource(Handle(thePrefs));
- end;
- otherwise
- ;
- end; { Case }
-
- end; { HitSample }
-
- {----------------------------------------------------------------}
-
- function IGetCtlHand (ourHandle: SampleHdl; item: Integer): ControlHandle;
-
- var
- itemHand: Handle;
- itemRect: Rect;
- itemType: Integer;
-
- begin
-
- with ourHandle^^ do
- GetDItem(dlgPtr, item + dlgItems, itemType, itemHand, itemRect);
- IGetCtlHand := ControlHandle(itemHand)
-
- end; { IGetCtlHand }
-
- {----------------------------------------------------------------}
-
- end.